<template>
  <!-- 费用（条码申请项目） -->
  <div id="wLapplicationItem">
    <Splitpanes :style="{ height: 'calc(100%)'}">
      <Pane :size="40">
        <div :style="{ height: 'calc(100% - 30px)'}">
          <vxe-table ref="WkflwNodeTableRef" :border="'none'" :expandAll="true" :expand-config="demo3.expandConfig" :expandRowKeys="defExpendKeys" height="auto" :row-config="{isCurrent:true,keyField:'id'}" :data="tableList">
            <!-- <vxe-column type="seq" width="20" class-name="text-bold text-shadow"></vxe-column> -->
            <vxe-column type="expand" title="方案名称">
              <template #default="{ row }">
                <span class="text-bold text-shadow">{{ row.workFlowNa }}</span>
              </template>
              <template #content="{ row, rowIndex }">
                <div v-if="row.bacTestWorkFlowNodes">
                  <div v-if="rowIndex === 1" style="display:none">{{row.id}}</div>
                  <div class="margin-left-lg margin-tb-xs">
                    <div :class="i!==0?'margin-top-sm':''" v-for="(m,i) in row.bacTestWorkFlowNodes" :key="i">
                      <span class="margin-right-xs bg-orange radius padding-lr-xs">{{`节点 ${i+1}`}}</span>
                      <span>{{m.nodeDictName}}</span>
                    </div>
                  </div>
                </div>
                <div v-else>
                  <div class="flex justify-center margin-tb text-gray">暂无节点</div>
                </div>
              </template>
            </vxe-column>
          </vxe-table>
        </div>
        <vxe-toolbar perfect>
          <template #buttons>
            <vxe-button type="text" class="button-blue" content="首选方案" status="primary" @click="changeSXWkflw"></vxe-button>
            <vxe-button type="text" class="button-blue margin-left-xs" content="备选方案" status="danger" @click="findBXWkflw"></vxe-button>
          </template>
        </vxe-toolbar>
      </Pane>
      <Pane :size="60">
        <div :style="{ height: 'calc(100% - 30px)'}">
          <vxe-table ref="testCultureMediumRef" v-loading="additionLoading" border height="auto" :data="tableCultureList" :footer-method="footerMethod" :merge-footer-items="[ { row: 0, col: 0, rowspan: 1, colspan: 4 } ]" :row-config="{ isCurrent: true, isHover: true }" :keyboard-config="{
              isArrow: true,
              isTab: true,
              isEdit: true
            }" resizable show-overflow @cell-dblclick="cultureMediumDbCellClick">
            <vxe-column title="" width="26" align="center">
              <template #default="{row}">
                <vxe-button type="text" @click="printCultureMediumBarcode(row)" style="padding:unset !important" class-name="clear-vxe-text-btn-class" class="clear-vxe-text-btn-class" status="success" icon="vxe-icon-print"></vxe-button>
              </template>
            </vxe-column>
            <vxe-column field="kind" title="类别" width="80">
              <template #default="{row}">
                <span v-if="row.kind==='1'">普通</span>
                <span v-else-if="row.kind==='2'">纯分</span>
                <span v-else-if="row.kind==='3'">转中</span>
                <span v-else>-</span>
              </template>
            </vxe-column>
            <vxe-column field="barcode" title="容器条码" width="120"></vxe-column>
            <vxe-column field="autoNo" title="自动编号" width="120"></vxe-column>
            <vxe-column field="cultureNa" title="培养基" min-width="120"></vxe-column>
          </vxe-table>
        </div>
        <vxe-toolbar perfect>
          <template #buttons>
            <vxe-button type="text" class="button-blue" content="新增" status="primary" @click="addCultureMedium"></vxe-button>
            <vxe-button type="text" class="button-red margin-left-xs" content="删除" status="danger" @click="deleteTestCultureMedium"></vxe-button>
            <vxe-button type="text" class="button-red margin-left-xs" content="全部删除" status="danger" @click="deleteAllTestCultureMediums"></vxe-button>
          </template>
        </vxe-toolbar>
      </Pane>
    </Splitpanes>

    <vxe-modal v-model="modalShow" id="specAdditionModal" width="65vw" height="45vh" show-zoom @hide="closeModal" :mask="false" destroy-on-close>
      <template #title>
        <span>培养基容器扫描</span>
      </template>
      <template #default>
        <vxe-toolbar>
          <template #buttons>
            <span class="margin-right-xs text-bold">容器条码</span>
            <vxe-input ref="specInput" v-model="specAdditionForm.reqNo" placeholder="请扫描容器条码" @keydown="scanBarcodeAction" clearable></vxe-input>
            <vxe-button type="text" class="button-blue margin-lr-xs" @click="saveTestCultureMediums">确定</vxe-button>
            <vxe-button type="text" class="button-blue margin-lr-xs" @click="closeModal">取消</vxe-button>
          </template>
        </vxe-toolbar>
        <div style="height:calc(100% - 40px)">
          <vxe-table ref="cultuTableRef" v-loading="additionLoading" border height="auto" :data="tableCultureListModal" :footer-method="footerMethod" :merge-footer-items="[ { row: 0, col: 0, rowspan: 1, colspan: 4 } ]" :row-config="{ isCurrent: true, isHover: true }" :keyboard-config="{
              isArrow: true,
              isTab: true,
              isEdit: true
            }" resizable show-overflow>
            <vxe-column field="cultureNa" title="培养基" min-width="80"></vxe-column>
            <vxe-column field="barcode" title="容器编码" width="120"></vxe-column>
            <vxe-column field="autoNo" title="自动编号" width="120"></vxe-column>
            <vxe-column field="bloodVal" title="血量(ml)" width="120"></vxe-column>
            <vxe-column field="totalWeight" title="总重量(g)" width="120"></vxe-column>
            <vxe-column field="minBloodVal" title="最小血量(ml)" width="120"></vxe-column>
            <vxe-column field="minTotalWeight" title="最小总重量(g)" width="120"></vxe-column>
            <vxe-column field="cultuMedWeight" title="培养瓶重量(g)" width="120"></vxe-column>
            <vxe-column field="cultuMedBarCodePrefix" title="容器条码前缀" width="120"></vxe-column>
            <vxe-column field="cultuMedBarCodeLength" title="容器条码长度" width="120"></vxe-column>
          </vxe-table>
        </div>
      </template>
    </vxe-modal>

    <!-- 选择备选方案 -->
    <vxe-modal v-model="modalShowBXWkflw" width="45vw" height="45vh" show-footer @hide="closeModalBXWkflw" :mask="false">
      <template #title>
        <span>备选方案</span>
      </template>
      <template #default>
        <div style="height:calc(100%)">
          <vxe-table ref="CultureCombinationRef" v-loading="loadingBxWkflw" border height="auto" :data="bxWkflwList" :merge-footer-items="[ { row: 0, col: 0, rowspan: 1, colspan: 4 } ]" :row-config="{ isCurrent: true, isHover: true }" :keyboard-config="{
              isArrow: true,
              isTab: true,
              isEdit: true
            }" resizable show-overflow>
            <vxe-column field="code" title="编号" width="80"></vxe-column>
            <vxe-column field="name" title="培养基组合" min-width="80"></vxe-column>
          </vxe-table>
        </div>
      </template>
      <template #footer>
        <vxe-button type="text" class="button-white margin-right" @click="closeModalBXWkflw">关闭</vxe-button>
        <vxe-button type="text" class="button-blue" @click="confirmCultureCombinationEvent">确定</vxe-button>
      </template>
    </vxe-modal>

    <!-- 单选培养基 -->
    <vxe-modal v-model="modalShowCultuMediumAll" width="35vw" height="85vh" show-footer @hide="closeModalCultuMediumAll" :mask="false">
      <template #title>
        <span>其他培养基</span>
      </template>
      <template #default>
        <div style="height:calc(100%)">
          <vxe-table ref="CultuMediumAllRef" v-loading="loadingCultuMediumAll" border height="auto" :data="cultuMediumAllList" :merge-footer-items="[ { row: 0, col: 0, rowspan: 1, colspan: 4 } ]" :row-config="{ isCurrent: true, isHover: true }" :keyboard-config="{
              isArrow: true,
              isTab: true,
              isEdit: true
            }" resizable show-overflow>
            <vxe-column type="checkbox" width="26" align="center"></vxe-column>
            <vxe-column field="code" title="培养基编号" width="90"></vxe-column>
            <vxe-column field="name" title="培养基名称" min-width="80"></vxe-column>
          </vxe-table>
        </div>
      </template>
      <template #footer>
        <vxe-button type="text" class="button-white margin-right" @click="closeModalCultuMediumAll">关闭</vxe-button>
        <vxe-button type="text" class="button-blue" @click="confirmCultureMediumEvent">确定</vxe-button>
      </template>
    </vxe-modal>
    <!-- 静默打印 -->
    <QuietPrint ref="quietPrintRef" :printParams="printParamsObj" />
  </div>
</template>
<script setup lang="ts">
import { getCurrentInstance, reactive, ref } from 'vue';
import { Pane, Splitpanes } from 'splitpanes';
import { IsEmpty, formatDateTime } from '@/utils/common';
import { VxeMessage, VxeNotifyType } from '@/utils/CommonMessage';
import 'vxe-table/lib/style.css';
import { VxeTablePropTypes, VXETable } from 'vxe-table';
import QuietPrint from '@/components/QuietPrint.vue';/**静默打印组件 */

let { proxy }: any = getCurrentInstance();

const demo3 = reactive({
  expandConfig: {
    visibleMethod({ row }) {
      return true;
    },
    iconOpen: 'vxe-icon-square-minus-fill',
    iconClose: 'vxe-icon-square-plus-fill'
  } as VxeTablePropTypes.ExpandConfig,
  tableData: []
});
const quietPrintRef = ref(null);/**静默打印组件对象 */
const testCultureMediumRef = ref(null);/**选用培养基组合列表对象 */
const CultureCombinationRef = ref(null);/**培养基组合列表组件对象 */
const WkflwNodeTableRef = ref(null);/**工作流程方案列表对象 */
const CultuMediumAllRef = ref(null);/**单选培养基弹窗列表对象 */
let modalShowBXWkflw = ref(false);/**备选方案弹窗 */
let modalShowCultuMediumAll = ref(false);/**单选培养基弹窗 */
let loadingBxWkflw = ref();/**备选方案加载中 */
let defExpendKeys = reactive([]);/**设置所选方案默认展开行 */
let reqNo = ref(''); //接收传过来的检验结果id
let rptGroup = ref(''); //接收传过来的检验结果id
let reqMainObj = reactive({});//申请对象
let tableList = reactive([]);/**流程方案 */
let tableCultureList = reactive([]);/**培养基列表 */
let tableCultureListModal = reactive([]);/**培养基列表 */
let specAdditionList = reactive([]);
let cultuMediumAllList = reactive([]);/**单选培养基弹窗列表数组 */
let loading = ref(false);
let additionLoading = ref(false);
let loadingCultuMediumAll = ref(false);
let applicationItemTableList = ref(null);
let modalShow = ref(false);
let operation = ref(false);
let isNotEdit = false;
let bxWkflwList = reactive([]);/**备选方案列表 */
let cultuTableRef = ref(null);/**弹窗培养基列表对象 */
let bxWkflwChangeAimList = reactive([]);/**备选培养方案 选用方案 */
let specAdditionForm = reactive({
  reqNo: '' //条码号)
}); //附加条码
let printParamsObj = ref(null);/**静默打印参数 */

defineExpose({
  isOperation,
  getreqDetail,
  showModal,
  getCultureDetail,
  getCultureDetailAsync,
  culutureScanBarCode,/**培养基扫码 */
});

/**培养基扫码 */
function isOperation(Operation: any) {
  operation.value = Operation;
}
/**培养基扫码 */
function culutureScanBarCode() {
  modalShow.value = true;
}
/**培养基双击事件 */
function cultureMediumDbCellClick({ row }) {
  tableCultureListModal.length = 0;
  Object.assign(tableCultureListModal, tableCultureList);
  modalShow.value = true;
}
// 页面加载列表
function getreqDetail(repData: any) {
  if (IsEmpty(repData) || !repData) {
    tableList.length = 0;
    return;
  }
  reqNo.value = '';
  if (!IsEmpty(repData.reqNo)) {
    reqNo.value = repData.reqNo;
  }
  if (!IsEmpty(repData.rptGroup)) {
    rptGroup.value = repData.rptGroup;
  }
  Object.assign(reqMainObj, repData);
  getDetail();
}

// 获取项目费用明细
function getDetail() {
  if (!reqNo.value) {
    return;
  }
  tableList.length = 0;
  defExpendKeys.length = 0;
  loading.value = true;
  const url = '/api/bac/bac-test-work-flow/findBacTestWorkFlowList';
  proxy.$http
    .get(url, { params: { reqNo: reqNo.value } })//, rptGroup: rptGroup.value, sampleda: formatDateTime(reqMainObj.signTime, 'yyyy-MM-dd hh:mm:ss') 
    .then(async (res: any) => {
      loading.value = false;
      Object.assign(tableList, res.data);
      WkflwNodeTableRef.value?.setCurrentRow(res.data[0]);
      //WkflwNodeTableRef.value?.setRowExpand([tableList[0]], true);
      proxy.$nextTick(async () => {
        await WkflwNodeTableRef.value?.setAllRowExpand(true);
      });
      getCultureDetail();
    })
    .catch((err: any) => {
      VxeMessage(err, VxeNotifyType.error);
    });
}

// 加载培养基
function getCultureDetail() {
  if (!reqNo.value) {
    return;
  }
  tableCultureList.length = 0;
  loading.value = true;
  const url = '/api/bac/bac-test-culture-medium/findBacTestCultureMediumList';
  proxy.$http
    .get(url, { params: { reqNo: reqNo.value } })
    .then(async (res: any) => {
      tableCultureList.length = 0;
      Object.assign(tableCultureList, res.data);
      loading.value = false;
    })
    .catch((err: any) => {
      VxeMessage(err, VxeNotifyType.error);
    });
}

function getCultureDetailAsync() {
  if (!reqNo.value) {
    return;
  }
  tableCultureList.length = 0;
  loading.value = true;
  const url = '/api/bac/bac-test-culture-medium/findBacTestCultureMediumList';
  return new Promise((resolve, reject) => {
    proxy.$http
      .get(url, { params: { reqNo: reqNo.value } })
      .then(async (res: any) => {
        tableCultureList.length = 0;
        Object.assign(tableCultureList, res.data);
        loading.value = false;
        let isPopup = false;
        tableCultureList.forEach((item: any) => {
          if (!IsEmpty(item.isAutoPopup) && item.isAutoPopup === true) {
            isPopup = true;
          }
        });
        if (isPopup) {
          cultureMediumDbCellClick({ row: tableCultureList[0] });
        }
        resolve(tableCultureList);
      })
      .catch((err: any) => {
        VxeMessage(err, VxeNotifyType.error);
        reject(err);
      });
  });
}


function addSpecAddition() {
  modalShow.value = true;
}

/**绑定培养瓶 */
function showModal() {
  modalShow.value = true;
}

function removeSpecAddition() {
  modalShow.value = true;
  return;

  const $table = (proxy.$refs.specAdditionListTable as any).getCurrentRecord();

  if (IsEmpty($table)) {
    proxy.$XModal.message({
      content: '请选择需要取消的附加条码',
      status: 'error'
    });
  }
  const url = '/lab/reqMain/deleteReqAdditions';
  const data = {
    id: $table.id,
    reqNo: $table.reqNo
  };
  proxy.$http
    .get(url, { params: data })
    .then(async (res: any) => {
      additionLoading.value = false;
      modalShow.value = false;
      if (res.status.code === 400) {
        VxeMessage(res.status.msg, VxeNotifyType.error);
      } else {
        VxeMessage('取消附加条码成功', VxeNotifyType.success);
      }
    })
    .catch((err: any) => {
      VxeMessage(err, VxeNotifyType.error);
    });
  return;
}

// 设置行类名
function setRowClassName() {
  /*if (row.isAdditional) {
    return 'spec-addition';
  }*/
}

// 关闭弹框
function closeModal() {
  modalShow.value = false;
  specAdditionForm.reqNo = '';
}
// 获取是否静态的tag标记(绿/红)
function getIsStaticTagType(row: any) {
  if (row.isAddition === 0) {
    return 'success';
  } else {
    return 'danger';
  }
}

// 保存
function saveSpecAddition() {
  additionLoading.value = true;
  if (IsEmpty(reqNo.value)) {
    VxeMessage('当前检验主记录没有条码号', VxeNotifyType.error);
  }
  if (IsEmpty(specAdditionForm.reqNo)) {
    VxeMessage('请输入附加条码号', VxeNotifyType.error);
  }
  const url = '/lab/reqMain/addReqAdditions';
  const data = {
    reqNo: reqNo.value,
    rptGroup: rptGroup.value,
    additionReqNo: specAdditionForm.reqNo
  };
  proxy.$http
    .get(url, { params: data })
    .then(async (res: any) => {
      additionLoading.value = false;
      modalShow.value = false;
      if (res.status.code === 400) {
        VxeMessage(res.status.msg, VxeNotifyType.error);
      } else {
        VxeMessage('附加条码成功', VxeNotifyType.success);
      }
    })
    .catch((err: any) => {
      VxeMessage(err, VxeNotifyType.error);
    });
}
// 表尾
function footerMethod({ columns, data }) {
  let count = 0;
  // specAdditionList.forEach(item => {
  //   count += item.costs ? parseFloat(item.costs) : 0;
  // });
  return [
    columns.map((column, _columnIndex) => {
      if (_columnIndex === 1) {
        return `金额合计: ${formatJe(count)}`;
      }
      return null;
    })
  ];
}
function formatJe(v) {
  if (Number.isNaN(v)) {
    return '';
  }
  return Number(v).toFixed(2);
}
/**切换加载首选方案 */
function changeSXWkflw() {
  // if (operation) {
  //   VxeMessage('检验记录已存在数据,请勿操作', VxeNotifyType.error);
  //   return;
  // }
  proxy.$http
    .get(`/lab/reqMain/findDefaultWkflwForBacReception`, { params: { ReqPurposeId: reqMainObj.purposeNo, sampleTypeNo: reqMainObj.sampleType } })
    .then(async (res: any) => {
      if (res && res.status && res.status.code === 1) {
        const type = await VXETable.modal.confirm(res.data);
        if (type === 'confirm') {
          proxy.$emit('changeSXWkflw', reqMainObj);
        }
      }
    })
    .catch((err: any) => {
      VxeMessage('新增药敏测试方法异常', VxeNotifyType.error);
    });
}
/**加载备选方案 */
function findBXWkflw() {
  if (operation) {
    VxeMessage('检验记录已存在数据,请勿操作', VxeNotifyType.error);
    return;
  }
  proxy.$http
    .get(`/lab/reqMain/findSecondWkflwForBacReception`, { params: { ReqPurposeId: reqMainObj.reqPurposeId, sampleTypeNo: reqMainObj.sampleType } })
    .then(async (res: any) => {
      if (res && res.status && res.status.code === 1 && res.data && !res.data.bacCultureCombinationList) {
        const type = await VXETable.modal.confirm('未配置相关备选方案');
      } else if (res && res.status && res.status.code === 1 && res.data && res.data.bacCultureCombinationList.length > 0) {
        modalShowBXWkflw.value = true;
        bxWkflwList.length = 0;
        bxWkflwChangeAimList.length = 0;
        Object.assign(bxWkflwList, res.data.bacCultureCombinationList);
        Object.assign(bxWkflwChangeAimList, res.data.bacWorkFlowList);
      }
    })
    .catch((err: any) => {
      VxeMessage('新增药敏测试方法异常', VxeNotifyType.error);
    });
}
/**关闭培养基组合选择弹窗 */
function closeModalBXWkflw() {
  modalShowBXWkflw.value = false;
}
/**确定选择培养基 */
function confirmCultureCombinationEvent() {
  const row = CultureCombinationRef.value?.getCurrentRecord();
  if (IsEmpty(row.id)) {
    VxeMessage('请选择一条培养基组合', VxeNotifyType.warning);
    return;
  }
  const data = {
    labReqMain: reqMainObj,
    bacWorkFlowList: [{ ...Object.assign({}, bxWkflwChangeAimList[0]) }],
    bacCultureCombinationList: [row]
  };
  proxy.$emit('changeBXWkflw', data);
  closeModalBXWkflw();
}
/**容器扫描条码 */
function scanBarcodeAction({ value, $event }) {
  if ($event.keyCode !== 13) {
    return;
  }
  const row = cultuTableRef.value?.getCurrentRecord();
  if (!row || IsEmpty(row.id)) {
    VxeMessage('请选择一条数据', VxeNotifyType.warning);
    return;
  }
  row.barcode = value;
}
/**保存选用培养基 */
function saveTestCultureMediums() {
  let url = `/api/bac/bac-test-culture-medium/batchUpdateBacTestCultureMedium`;
  proxy.$http
    .post(url, tableCultureListModal)
    .then((res: any) => {
      if (res && res.status && res.status.code !== 1) {
        VxeMessage(res.status.msg, VxeNotifyType.error);
      } else if (res && res.status && res.status.code === 1) {
        tableCultureList.length = 0;
        VxeMessage(res.status.msg, VxeNotifyType.success);
        Object.assign(tableCultureList, res.data);
        closeModal();
      } else {
        VxeMessage('请求错误', VxeNotifyType.error);
      }
    })
    .catch((err: any) => {
      VxeMessage('操作失败,请联系管理员', VxeNotifyType.error);
    });
}
/**新增其他培养基 */
function addCultureMedium() {
  if (operation) {
    VxeMessage('检验记录已存在数据,请勿操作', VxeNotifyType.error);
    return;
  }
  cultuMediumAllList.length = 0;
  loadingCultuMediumAll.value = true;
  proxy.$http
    .get(`/api/bac/bac-culture-medium/findBacCultureMediumList`)
    .then(async (res: any) => {
      Object.assign(cultuMediumAllList, res.data);
      loadingCultuMediumAll.value = false;
    })
    .catch((err: any) => {
      loadingCultuMediumAll.value = false;
      VxeMessage('加载培养基失败', VxeNotifyType.error);
    });
  modalShowCultuMediumAll.value = true;
}
/**关闭单选培养基弹窗 */
function closeModalCultuMediumAll() {
  modalShowCultuMediumAll.value = false;
}
/**确认选择其他培养基 */
function confirmCultureMediumEvent() {
  const rows = CultuMediumAllRef.value?.getCheckboxRecords(true);
  if (!rows || rows.length <= 0) {
    VxeMessage('请先勾选培养基', VxeNotifyType.warning);
    return;
  }
  let arr = [];
  rows.forEach((e, i) => {
    const m = tableCultureList.filter(p => p.cultureNo === e.code && p.cultureId === e.id);
    if (m && m.length > 0) {
      //todo
    } else {
      const a = {
        maininfoId: null,
        reqMainId: reqMainObj.id,
        reqNo: reqMainObj.reqNo,
        kind: '',
        barcode: '',
        cultureId: e.id,
        cultureNo: e.code,
        cultureNa: e.name,
        cultureCombinId: '',
        cultureCombinNo: '',
        cultureCombinNa: '',
        isPrintLabel: 0,
        printLabelCount: 0,
        seq: tableCultureList.length + 1
      };
      arr.push(a);
    }
  });
  if (arr.length <= 0) {
    closeModalCultuMediumAll();
    return;
  }
  let url = `/api/bac/bac-test-culture-medium/batchInsertBacTestCultureMedium`;
  proxy.$http
    .post(url, arr)
    .then((res: any) => {
      if (res && res.status && res.status.code !== 1) {
        VxeMessage(res.status.msg, VxeNotifyType.error);
      } else if (res && res.status && res.status.code === 1) {
        getCultureDetail();
        closeModalCultuMediumAll();
      } else {
        VxeMessage('请求错误', VxeNotifyType.error);
      }
    })
    .catch((err: any) => {
      VxeMessage('操作失败,请联系管理员', VxeNotifyType.error);
    });
}
/**删除培养基 */
async function deleteTestCultureMedium() {
  if (operation) {
    VxeMessage('检验记录已存在数据,请勿操作', VxeNotifyType.error);
    return;
  }
  const row = testCultureMediumRef.value?.getCurrentRecord();
  if (!row) {
    VxeMessage('请选中要删除的行', VxeNotifyType.warning);
    return;
  }
  const type = await VXETable.modal.confirm(`确定要删除选中的数据?`);
  if (type === 'confirm') {
    let url = `/api/bac/bac-test-culture-medium/deleteBacTestCultureMedium`;
    proxy.$http
      .post(url, row)
      .then((res: any) => {
        if (res && res.status && res.status.code !== 1) {
          VxeMessage(res.status.msg, VxeNotifyType.error);
        } else if (res && res.status && res.status.code === 1) {
          getCultureDetail();
        } else {
          VxeMessage('请求错误', VxeNotifyType.error);
        }
      })
      .catch((err: any) => {
        VxeMessage('操作失败,请联系管理员', VxeNotifyType.error);
      });
  }
}
/**全部删除培养基 */
async function deleteAllTestCultureMediums() {
  if (operation) {
    VxeMessage('检验记录已存在数据,请勿操作', VxeNotifyType.error);
    return;
  }
  const type = await VXETable.modal.confirm(`确定要全部删除培养基数据?`);
  if (type === 'confirm') {
    let url = `/api/bac/bac-test-culture-medium/allDeleteBacTestCultureMedium`;
    proxy.$http
      .post(url, { reqMainId: reqMainObj.id })
      .then((res: any) => {
        if (res && res.status && res.status.code !== 1) {
          VxeMessage(res.status.msg, VxeNotifyType.error);
        } else if (res && res.status && res.status.code === 1) {
          getCultureDetail();
        } else {
          VxeMessage('请求错误', VxeNotifyType.error);
        }
      })
      .catch((err: any) => {
        VxeMessage('操作失败,请联系管理员', VxeNotifyType.error);
      });
  }
}

/**打印培养基条码 */
function printCultureMediumBarcode(row) {
  let url = `/api/pubReport/getReportByBusFormCode?code=006`;
  proxy.$http
    .get(url)
    .then((res: any) => {
      if (res && res.status && res.status.code === 1 && res.data && !IsEmpty(res.data.id)) {
        printParamsObj.value = [{ ReportName: res.data.id, ReportParameters: [{ Name: 'Id', Value: row.id }], PdfPrinterSetting: { PdfPrinterCopies: 1 } }];
      } else {
        proxy.$alert('查无容器条码模板', '提示');
      }
    })
    .catch((err: any) => {
      proxy.$alert('查询容器条码模板失败', '提示');
      //VxeMessage('操作失败,请联系管理员', VxeNotifyType.error);
    });
  //printParamsObj.value = [{ ReportName: '1779903240373112834', ReportParameters: [{ Name: 'code', Value: v }], PdfPrinterSetting: { PdfPrinterCopies: 1 } }];
}
</script>
<style lang="scss" scoped>
#wLapplicationItem {
  height: 100%;
}
:deep(.vxe-table--render-default .vxe-body--expanded-column) {
  border-bottom: unset !important;
}
</style>
